package com.service.impl;

import java.io.IOException;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dao.UserDao;
import com.entity.User;
import com.service.UserService;

@Transactional // 类所有方法都支持事物
@Service // 业务层
public class UserServiceImpl implements UserService {

	@Autowired
	UserDao userDao;

	@Override
	public List<User> selectUser() {
		return userDao.selectUser();
	}

	// 该方法支持事物
	@Transactional(rollbackFor = Exception.class)
	@Override
	public int deleteUserById(Integer id) throws IOException {
		int n = userDao.deleteUserById(id);
		System.out.println("影响行数:" + n);

		throw new IOException("IOException");
	}

}
